$(function() {
	
	$('.btn-area').on('click',function() {
		     window.location.href="submit.html";
		})

			$.ajax({
					type: "post",
					url: "http://localhost:8080/mall/findAlladdress",
					dataType: "json",
					success: function(data) {
						var data=data.message
						console.log(data)
						var str=``;
						for(var i=0;i<2;i++){
							str+=`
							<div class="zuijia">
								
								<a>姓名:${data[i].name}</a><br/>
								<a>电话:${data[i].tel}</a><br/>
								<a>地址:${data[i].address}</a>
								</div>
							`
						}
						$(".some").html(str)
						}
					})

				$(".add").on('click', function() {
					$("form").show();
					$(".save").on('click', function() {
						let sname = $(".sname").val();
						let sphone = $(".sphone").val();
						let saddress = $(".saddress").val();
						$.ajax({
							type: "post",
							url: "http://localhost:8080/mall/addAddress",
							dataType: "json",
							data: {
								"name": sname,
								"address": saddress,
								"tel": sphone
							},
							success: function(data) {
								var li = $("<li></li>")
								li.html(sname + saddress + sphone)
								// console.log(value)
								// $(".zuijia ul").appendChild(li)
								$(".zuijia ul").prepend(li);

							},
						})
					})




				})
			})



